/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:${USER}
 * Date:${YEAR}-${MONTH}-${DAY}
 * ${TIME}
 */
public class Main {
    public static void main(String[] args) {
        System.out.println("Hello world!");
    }
}
class Solution {
    public int minSubArrayLen(int target, int[] nums) {
        int n=nums.length;
        int sum=0;
        int len=Integer.MAX_VALUE;
        for(int left=0,right=0;right<n;right++){
            sum+=nums[right];//进窗口
            while(sum>=target){
                len=Math.min(len,right-left+1);//更新结果

                sum-=nums[left++];//出窗口
            }
        }
        return len==Integer.MAX_VALUE?0:len;
    }
}